﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace QuanLyThuoc.DAL
{
    class LoaiThuocDAL:KetNoiDAL
    {
        public DataTable SelectAll_LoaiThuoc()
        {
            SqlCommand cmd = new SqlCommand("SelectAll_LoaiThuoc", Connect());
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
        public DataTable SelectID_LoaiThuoc(string LoaiThuoc)
        {
            SqlCommand cmd = new SqlCommand("SelectID_LoaiThuoc", Connect());
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@LoaiThuoc", LoaiThuoc);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
        public int InsertLoaiThuoc(string loaithuoc)
        {
           
                SqlCommand cmd = new SqlCommand("Insert_LoaiThuoc", Connect());
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@LoaiThuoc", loaithuoc);
              return  cmd.ExecuteNonQuery();
           
        }
        public int UpdateLoaiThuoc(string loaithuoc)
        {
           
                SqlCommand cmd = new SqlCommand("Update_LoaiThuoc", Connect());
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@LoaiThuoc", loaithuoc);
             return   cmd.ExecuteNonQuery();
            
        }
        public int DeleteLoaiThuoc(string loaithuoc)
        {
            
                SqlCommand cmd = new SqlCommand("Delete_LoaiThuoc", Connect());
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@LoaiThuoc", loaithuoc);
              return  cmd.ExecuteNonQuery();
           
        }
    }
}
